package com.usian.user.config;

import com.usian.user.service.IChatStreamAssistant;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import dev.langchain4j.service.AiServices;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LLMConfig {

    @Bean
    public StreamingChatLanguageModel streamingChatLanguageModel(){
        return OpenAiStreamingChatModel.builder()
                .apiKey("sk-cdfa40dd61e24273b7ef38c3613fb425")
                .modelName("qwen-max")
                // 是否打印请求日志
                .logRequests(true)
                // 是否打印响应日志
                .logResponses(true)
                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                .build();
    }
    @Bean
    public IChatStreamAssistant chatStreamAssistant() {
        return AiServices.builder(IChatStreamAssistant.class)
                .streamingChatLanguageModel(streamingChatLanguageModel())
                .build();
    }

}
